<!--
 * @Description:
 * @Version:
 * @Autor: ps
 * @Date: 2022-09-08 11:43:43
 * @LastEditors: ps
 * @LastEditTime: 2022-09-13 16:44:53
-->
<template>
  <div class="ce-reduction">
    <pieChart :pieData="dataArr" />
  </div>
</template>

<script>
import pieChart from "@/views/home/reduction/components/pieChart.vue";
export default {
  name: "ce-reduction",
  props: {
    activeName: {
      type: String,
      default: "0",
    },
  },
  components: {
    pieChart,
  },
  data() {
    return {
      dataArr: [],
    };
  },
  watch: {
    activeName: {
      handler(val) {
        if (val && val == "1") {
          setTimeout(() => {
            this.getpieData();
          }, 500);
        }
      },
      immediate: true,
      deep: false,
    },
  },
  // mounted() {
  //   this.getpieData();
  // },
  beforeDestroy() {
    this.reset();
  },
  methods: {
    reset() {
      this.dataArr = [];
    },
    getpieData() {
      this.dataArr = [
        { value: 0, name: "电耗" },
        { value: 0, name: "水耗" },
        { value: 0, name: "视频会议" },
        { value: 0, name: "台账无纸化" },
        { value: 0, name: "光伏发电" },
      ];
    },
  },
};
</script>

<style scoped lang="scss">
.ce-reduction {
  width: 100%;
}
</style>
